package week_09;

import java.util.*;

public class Dishu {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int m = input.nextInt();
        int[][] dishu = new int[n][2];
        int[][] plants = new int[m][2];
        // 读n行地鼠行踪
        for (int i = 0; i < n; i++) {
            dishu[i][0] = input.nextInt();
            dishu[i][1] = input.nextInt();
        }
        // 读m行植物位置
        for (int i = 0; i < m; i++) {
            plants[i][0] = input.nextInt();
            plants[i][1] = input.nextInt();
        }

        // 记录植物位置
        Map<String, Boolean> isPlants = new HashMap<>();
        for (int[] site : plants) {
            String key = hashKey(site);
            isPlants.put(key, true);
        }
        // 记录地鼠活动次数
        Map<String, Integer> countMap = new HashMap<>();
        for (int[] site : dishu) {
            String key = hashKey(site);
            int count = countMap.getOrDefault(key, 0);
            countMap.put(key, count + 1);
        }

        //将map.entrySet()转换成list 进行排序
        List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(countMap.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
            //降序排序
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if (o2.getValue() != o1.getValue()) {
                    return o2.getValue().compareTo(o1.getValue());
                } else {

                    return keyCompare(o1.getKey(), o2.getKey());
                }
            }
        });

        // 找答案 ： 次数最多且不是植物的位置，如果有多个则返回
        // 1.x+y 最小
        // 2.x 最小
        String[] ans = new String[2];
        for (Map.Entry<String, Integer> entry : list) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
            String key = entry.getKey();
            if (!isPlants.containsKey(key)) {
                String[] split = key.split("-");
                ans[0] = split[1];
                ans[1] = split[2];
                break;
            }
        }
        System.out.println(ans[0] + " " + ans[1]);
    }

    public static int keyCompare(String key1, String key2) {
        String[] s1 = key1.split("-");
        String[] s2 = key2.split("-");
        int i1 = Integer.valueOf(s1[0]);
        int i2 = Integer.valueOf(s2[0]);

        if (i1 != i2) {
            return i1 - i2;
        } else {
            int x1 = Integer.valueOf(s1[1]);
            int x2 = Integer.valueOf(s2[1]);
            return x1 - x2;
        }

    }

    public static String hashKey(int[] site) {
        return (site[0] + site[1]) + "-" + site[0] + "-" + site[1];
    }
}
